// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-12

package kind

// TicketTime
// 作钓时段.
type TicketTime int

const (
	TicketTimeStrict TicketTime = 1 // 同时开钓/严格模式
	TicketTimeLoose  TicketTime = 2 // 随到随钓/宽松模式
)

var (
	ticketTimeTexts = map[TicketTime]string{
		TicketTimeStrict: "同时开钓",
		TicketTimeLoose:  "随到随钓",
	}
	ticketTimeUndefined = "错误"

	ticketTimeFlags = map[TicketTime]string{
		TicketTimeStrict: "strict",
		TicketTimeLoose:  "loose",
	}
	ticketTimeUnknownFlag = "unknown"
)

func TicketTimeDict() []map[string]any {
	var res = make([]map[string]any, 0)
	for _, v := range []TicketTime{
		TicketTimeStrict,
		TicketTimeLoose,
	} {
		res = append(res, map[string]any{
			"Key":   v,
			"Value": v.Text(),
		})
	}
	return res
}

func (o TicketTime) Flag() string {
	if str, ok := ticketTimeFlags[o]; ok {
		return str
	}
	return ticketTimeUnknownFlag
}

func (o TicketTime) IsLoose() bool  { return o == TicketTimeLoose }
func (o TicketTime) IsStrict() bool { return o == TicketTimeStrict }

func (o TicketTime) Text() string {
	if str, ok := ticketTimeTexts[o]; ok {
		return str
	}
	return ticketTimeUndefined
}
